<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./css/index.css">
    <style>
        .in-style{
            width: 600px;
            height: 300px;
            margin: 0 auto;
            margin-top: 30vh;
            /* border: 1px solid red; */
        }
        .border-circular-left{
            width: 30px;
            height: 30px;
            /* border: 1px solid black; */
            border-radius: 50%;
            margin-top: 20px;
        }
        .border-circular-right{
            width: 30px;
            height: 30px;
            /* border: 1px solid black; */
            border-radius: 50%;
            margin-top: 20px;
        }
        .border-circular-bottom{
            width: 30px;
            height: 30px;
            /* border: 1px solid black; */
            border-radius: 50%;
            margin-left:20px;
        }
        .border-circular-top{
            width: 30px;
            height: 30px;
            /* border: 1px solid black; */
            border-radius: 50%;
            margin-left:20px;
        }
        .border-circular{
            width: 30px;
            height: 30px;
            /* border: 1px solid black; */
            border-radius: 50%;
            margin-top: 20px;
            
        }
        .word-style{
            width: 400px;
            margin: 0 auto;
            text-align: center;
            font-size: 20px;
        }
        .left-color{
            position: absolute;
            width: 150px;
            height: 100%;
            left: 0;
            top: 0;
        }
        .right-color{
            position: absolute;
            /* width: 150px; */
            height: 100%;
            right: 0;
            top: 0;
        }
        .bottom-color{
            position: absolute;
            display: flex;
            bottom: 0;
            height: 35px;
            left: 15px;
        }
        .top-color{
            position: absolute;
            display: flex;
            top: 0;
            left: 15px;
            height: 50px;
        }
        .startClass{
            width: 70px;
            margin: 0 auto;
            /* padding-left: 20px; */
            /* margin-left: 50px; */
            margin-top: 20px;
            cursor: pointer;
            border-bottom: 1px solid black;
        }
    </style>
</head>
<body>
    <div class="left-color" id="left-border">
        
    </div>
    <div class="right-color" id="right-border">
        
    </div>
    <!-- <div class="bottom-color" id="bottom-border">
        
    </div>
    <div class="top-color" id="top-border">
        
        </div> -->
    <div class="in-style">
        <div class="word-style">
                <span>WHAT'S YOUR LUCKY COLOR FOR TODAY?</span> <style 1000px></style>
                <div class="startClass" onclick="buttonClick()">
                        START
                </div>
                <div class="border-circular" id="circular">
        </div>
        
            
        </div>
    </div>
    <script>

        let colorList = ["red","pink","purple","orange","yellow","green","blue"]
        let circular = document.getElementById("circular")
        var leftBorder = document.getElementById("left-border")
        for(let i = 0 ;i<15;i++){
           let div = document.createElement("div")
           div.className = "border-circular-left"
           div.style.backgroundColor = colorList[i%7]
            leftBorder.appendChild(div)
        }
        var rightBorder = document.getElementById("right-border")
        for(let i = 0 ;i<15;i++){
           let div = document.createElement("div")
           div.className = "border-circular-right"
           div.style.backgroundColor = colorList[i%7]
           rightBorder.appendChild(div)
        }
        // var bottomBorder = document.getElementById("bottom-border")
        // for(let i = 0 ;i<29;i++){
        //    let div = document.createElement("div")
        //    div.className = "border-circular-bottom"
        //    div.style.backgroundColor = colorList[i%7]
        //    bottomBorder.appendChild(div)
        // }
        // var topBorder = document.getElementById("top-border")
        // for(let i = 0 ;i<29;i++){
        //    let div = document.createElement("div")
        //    div.className = "border-circular-top"
        //    div.style.backgroundColor = colorList[i%7]
        //    topBorder.appendChild(div)
        // }
        var count = 0
        setInterval(() => {
            count++
            let leftDiv = document.getElementsByClassName("border-circular-left")
            for(let i = 0;i<15;i++){
                leftDiv[i].style.backgroundColor = colorList[(count+i)%7]
            }
            let rightDiv = document.getElementsByClassName("border-circular-right")
            for(let i = 0;i<15;i++){
                rightDiv[i].style.backgroundColor = colorList[(count+i)%7]
            }
            // let toptDiv = document.getElementsByClassName("border-circular-top")
            // for(let i = 0;i<29;i++){
            //     toptDiv[i].style.backgroundColor = colorList[(count+i)%7]
            // }
            // let bottmoDiv = document.getElementsByClassName("border-circular-bottom")
            // for(let i = 0;i<29;i++){
            //     bottmoDiv[i].style.backgroundColor = colorList[(count+i)%7]
            // }
        }, 1000);

       



        // 点击按钮触发事件
        function buttonClick(){
            // let randomNumber = Math.floor(Math.random()*7) 
            // circular.style.backgroundColor = colorList[randomNumber]
            // setTimeout(()=>{
                window.location = `index.html`
            // },1000)
        }
    
    </script>
</body>
</html>